package org.usmile.algorithms.huawei.acm;

import java.util.*;

// https://blog.csdn.net/qq_34465338/article/details/128356984
public class _最多等和不相交连续子序列 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] numStr = sc.nextLine().split(" ");
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Integer.parseInt(numStr[i]);
        }

        Map<Integer, List<int[]>> sumMap = new HashMap<>();
        for (int start = 0; start < n; start++) {
            int currSum = nums[start];
            for (int end = start; end < n; end++) {
                if (start != end) {
                    currSum += nums[end];
                }

                if (sumMap.containsKey(currSum)) {
                    sumMap.get(currSum).add(new int[]{start, end});
                } else {
                    List<int[]> list = new ArrayList<>();
                    list.add(new int[]{start, end});
                    sumMap.put(currSum, list);
                }
            }
        }

        int max = 0;
        loop:
        for (List<int[]> sumList : sumMap.values()) {
            int end = sumList.get(0)[1];
            int size = 1;
            for (int i = 1; i < sumList.size(); i++) {
                if (sumList.get(i)[0] > end) {
                    size++;
                    end = sumList.get(i)[1];
                }
            }

            max = Math.max(max, size);
        }

        System.out.println(max);
    }
}
